<?php

namespace app\dao\posts;

use app\dao\BaseDao;
use app\model\posts\PostComments;

/**
 * 帖子评论
 * Class PostsDao
 * @package app\dao\posts
 */
class PostCommentsDao extends BaseDao
{
    /**
     * 设置模型
     * @return string
     */
    protected function setModel(): string
    {
        return PostComments::class;
    }

    public function search(array $where = [], bool $search = true)
    {
        return $this->getModel()
            ->when(isset($where['post_id']) && $where['post_id'] != 0, function ($query) use ($where) {
                $query->where('post_id', $where['post_id']);
            });
    }
}